#ifndef TYPES_MODULE
#define TYPES_MODULE

#include <WinSock2.h>

typedef char* IpAdress;

// an enum for the different modes (node type)
typedef enum {
	MODE_CLOCK, 
	MODE_BATTERY,
	MODE_INTERCEPTOR,
	MODE_MANAGER,
	MODE_SIMULATOR
} TMode;

//a Vector with an X,Y double parameters
typedef struct {
	double x;
	double y;
} TVector;


//Defining the two types of vectors
typedef TVector TPosition;
typedef TVector TVelocity;

// contains parameters for newly launched rockets.
typedef struct 
{
	TPosition InitialPosition;
	TVelocity InitialVelocity;
	int FlightTime;
} TInitialRocketInfo;

//an enum for the differnet rocket types according its age
typedef enum {
	ROCKET_TYPE_NULL,
	ROCKET_TYPE_DANDASH,
	ROCKET_TYPE_NEW,
	ROCKET_TYPE_KNOWN,
	ROCKET_TYPE_DISAPPEARED
} TRocketType;

//an enum for the differnet Rockets or interceptor status
typedef enum {
	M_STATUS_IN_BATTERY,
	M_STATUS_HIT_GROUND,
	M_STATUS_SELF_DESTRUCT,
	M_STATUS_EXPLODED,
	M_STATUS_INTERCEPTED,
	M_STATUS_ACTIVE
} TM_Status;


// an interceptor linked list node containing all the paramaters of the interceptor including its sockets
typedef struct _TInterceptor
{
	SOCKET Socket;
	int RocketID;
	TM_Status Status;
	TPosition Position;
	TVelocity Velocity; 
	double InterceptDistance;
	double SuccessRate;
	struct _TInterceptor *NextInterceptor;
} TInterceptor;

// a sturct containing a pointer to the linked list of interceptors and info about the linked list
typedef struct
{
	TInterceptor *FirstInterceptor;
	int NumOfFlyingInterceptors;
	int NumOfInterceptors;
} TInterceptorsList;


//a struct containing the battery's paramaters, sockets and connected interceptors info
typedef struct
{
	TPosition Position;
	char *BatteryIP;
	int BatteryPort;
	int NumOfAvailableInterceptors;
	int NumOfFlyingInterceptors;
	int TotalNumOfInterceptors; 
	TInterceptorsList *InterceptorsList;
	SOCKET Socket;
} TBattery;

// a rocket linked list node containing all the paramaters of the rocket including a pointer to its chasing battery.
typedef struct _TRocket
{
	int RocketID;
	BOOL Launched;
	TM_Status Status;
	int LifeTime;
	int Sightings;
	TRocketType RocketType;
	TPosition Position;
	TVelocity Velocity;
	TBattery *ChasingBattery;
	struct _TRocket *NextRocket;
} TRocket;

// a sturct containing a pointer to the linked list of rockets and info about the linked list
typedef struct 
{
	TRocket *FirstRocket;
	int NumOfRockets;
} TRocketsList;


// An enum for different types of errors.
typedef enum {
	ERROR_ALLOCATING_MEMORY, 
	ERROR_CREATING_THREAD, 
	ERROR_RECEIVING_MESSAGE, 
	ERROR_SENDING_MESSAGE,
	ERROR_AT_WSAStartup,
	ERROR_WAITING_FOR_SINGLE_OBJECT, 
	ERROR_WAITING_FOR_MULTIPLE_OBJECT, 
	ERROR_WRITING_TO_FILE,
	GENERAL_ERROR
}TError;

//An enum for the different types of Actions sent by the different nodes.
typedef enum
{
	ACTION_BEGINNING_OF_ROUND,
	ACTION_END_OF_ROUND,
	ACTION_END_OF_ROUND_TO_CLOCK,
	ACTION_END_OF_GAME,
	ACTION_LAUNCH_INTERCEPTOR,
	ACTION_LAUNCH_REFUSAL,
	ACTION_UPDATE_INTERCEPTOR_ON_ROCKET_INFO,
	ACTION_SELF_DESTRUCT,
	ACTION_CHANGE_BATTERIES,
	ACTION_UPDATE_CURRENT_POSITION,
	ACTION_UPDATE_CURRENT_DIRECTION,
	ACTION_UPDATE_POSITIONS_MAP,
	ACTION_NOTIFY_INTERCEPTOR_TO_CHANGE_BATTERY,
	ACTION_INITIAL_INTERCEPTOR_INFO_UPDATE,
	ACTION_ROCKET_EXPLODED,
	ACTION_REGISTRATION,
	ACTION_INTERCEPTED,
	ACTION_IN_BATTERY
}TActionType;

#endif

